package com.weng.bigdata.core.database.enums;

/**
 *  数据库驱动枚举
 * @author wengzhonghui
 * @date 10:44 2021/3/23
 */
public enum DbDriverEnum {
	MYSQL("com.mysql.jdbc.Driver","mysql"),
	SQLSERVER("com.microsoft.sqlserver.jdbc.SQLServerDriver", "sqlServer"),
	ORACLE("oracle.jdbc.OracleDriver", "oracle"),
	POSTGRESQL("org.postgresql.Driver", "postgreSql");

	DbDriverEnum(String driver, String dbType) {
		this.driver = driver;
		this.dbType = dbType;
	}

	private String driver;
	private String dbType;

	public String getDriver() {
		return driver;
	}

	public void setDriver(String driver) {
		this.driver = driver;
	}

	public String getDbType() {
		return dbType;
	}

	public void setDbType(String dbType) {
		this.dbType = dbType;
	}

	public static String getDriver(String dbType){
		if(dbType != null){
			dbType = dbType.trim();
		}
		for(DbDriverEnum c: DbDriverEnum.values()){
			if(c.getDbType().equals(dbType)){
				return c.getDriver();
			}
		}

		return null;
	}

}
